<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${staticUrl}/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="${staticUrl}/css/personinfo.css">
    <#--<script src="${staticUrl}/js/html5shiv.js"></script>-->
</head>
<body>
<#include "common/header.ftl">

<div class="center">
    <div class="title">
        <h1 class="info">请确认修改信息</h1>
        <div style="height:20px;"></div>
        <p class="remind">请保证姓名、手机号已经填写，否则其他功能无法使用</p>
    </div>
    <div class="form-content">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input type="text"  name="name" autocomplete="off" placeholder="姓名由2-4个汉字组成" class="layui-input" required  value="${user.name!''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">账户</label>
                <div class="layui-input-block">
                    <input type="text" name="username" autocomplete="off" class="layui-input layui-disabled" disabled value="${user.username!''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="pass" placeholder="请输入新密码" maxlength="16" class="layui-input"><i class="show_pass"></i>
                </div>
            </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-block">
                        <input type="text" name="phone" autocomplete="off" class="layui-input" required value="${user.phone!''}">
                    </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">学校名称</label>
                <div class="layui-input-block">
                    <input type="text" name="school" class="layui-input layui-disabled" disabled value="${user.school!''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">学校简称</label>
                <div class="layui-input-block">
                    <input type="text" name="schoolAbbreviation" class="layui-input layui-disabled" disabled value="${user.schoolAbbreviation!''}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">班级</label>
                <div class="layui-input-block">
                    <input type="text" name="classes" class="layui-input layui-disabled" disabled value="${user.classes!''}">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">账户有效期</label>
                    <div class="layui-input-inline" style="width: 120px; left: 50px">
                        <input type="text" name="startTime"  autocomplete="off" class="layui-input layui-disabled" disabled value="${user.startTime!''}">
                    </div>
                    <div class="layui-form-mid" style="left: 50px">-</div>
                    <div class="layui-input-inline" style="width: 120px;left: 50px">
                        <input type="text" name="endTime"  autocomplete="off" class="layui-input layui-disabled" disabled value="${user.endTime!''}">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center; margin-top: 30px">
                    <input id="submit-btn" type="button" class="layui-btn m_submit" value="确认提交"/>
            </div>
        </form>
    </div>
</div>
<script src="${staticUrl}/plugins/jquery/jquery-3.2.1.min.js"></script>
<script src="${staticUrl}/plugins/layui/layui.all.js"></script>
<script src="${staticUrl}/js/md5.js"></script>
<script type="text/javascript">
    $("#submit-btn").on('click',function () {
        var phone = $("input[name=phone]").val();
        var name = $("input[name=name]").val();
        if(checkphone(phone) && checkName(name)){
            var name = $('input[name=name]').val();
            var pass = $('input[name=pass]').val();
            if(pass && pass.length < 6){
                alert('密码长度不能小于6位');
                return;
            }
            if(pass && pass.length > 5){
                pass = set(pass);
            }else{
                pass = '';
            }
            $.post({
                url:"myInfo",
                dataType:'text',
                data:{"phone":phone,"password":pass,"name":name},
                success:function (resText) {
                    alert(resText);
                }
            });
            return false;
        }
        return false;
    })

	function set(pw){
	    return hex_md5(pw);
	}
	function checkName(str){
	reg = /^[\u4E00-\u9FA5]{2,4}$/;
	if(reg.test(str)){
		return true;
	}
	alert("姓名格式错误，请输入2-4位汉字");
	return false;
	}
    function checkphone(str){
        var re= /^[1][3,4,5,7,8][0-9]{9}$/;
        if(re.test(str))
            return true;
        alert("手机号码格式错误");
        return false;

    }
    $(".show_pass").mousemove(function () {
        $("input[name=pass]").attr("type","text");
    })
    $(".show_pass").mouseleave(function () {
        $("input[name=pass]").attr("type","password");
    })
</script>
</body>
</html>